﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;
using BCNPCObject.DB;
using DbLinq;
using DbLinq.Oracle;
using CMISLibrary.Entities;
using CMISLibrary;

namespace BCNPCObject
{
    public class cls_NPC_CHAMNO_OFFLINE_Controller
    {
        #region   Atributes

        private DataSet CMIS_Header = new CMISOutputParameter();
        private DataSet ds = new DataSet();
        private DataTable dt = new DataTable();
        private NPC_CHAMNO_OFFLINE info;

        #endregion

        #region   Constructor

        public cls_NPC_CHAMNO_OFFLINE_Controller()
        {
            info = new NPC_CHAMNO_OFFLINE();
        }
        public cls_NPC_CHAMNO_OFFLINE_Controller(NPC_CHAMNO_OFFLINE Info)
        {
            this.info = Info;
        }

        #endregion

        #region   Properties

        public NPC_CHAMNO_OFFLINE pInfor
        {
            get { return info; }
            set { info = value; }
        }

        #endregion

        #region  DungNT NPC

        public long GetSequence(ref string str)
        {
            try
            {
                long _id = CMIS2.DB.ExecuteCommand("select SEQ_NPC_CHAMNO_OFFLINE.nextval from dual", ref str);
                if (str.Trim().Length > 0) return -1;
                return _id;
            }
            catch
            {
                //CMIS2.ResetDB(); 
                return -1;
            }
        }

        public bool insert_NPC_CHAMNO_OFFLINE(ref string str)
        {
        try
            {
                long _ID_OFFLINE = GetSequence(ref str);
                if (_ID_OFFLINE == -1) return false;

                NPC_CHAMNO_OFFLINE objNPC_CHAMNO_OFFLINE = new NPC_CHAMNO_OFFLINE
            {
                MA_DVIQLY = info.MA_DVIQLY,
                ID_OFFLINE = _ID_OFFLINE,
                ID_HDON = info.ID_HDON,
                MA_TNGAN = info.MA_TNGAN,
                SO_BBGIAO = info.SO_BBGIAO,
                TIEN_NOP = info.TIEN_NOP,
                THUE_NOP = info.THUE_NOP,
                NGAY_CHAMNO = info.NGAY_CHAMNO,
                NGUOI_TAO = info.NGUOI_TAO,
                NGAY_TAO = info.NGAY_TAO,
                THANG_HT = info.THANG_HT,
                NAM_HT = info.NAM_HT
            };
                CMIS2.DB.NPC_CHAMNO_OFFLINE.InsertOnSubmit(objNPC_CHAMNO_OFFLINE);
            return true;
            }
            catch
            { 
            return false; 
            }
        }
#endregion
     
    }
}

